from header_common import *
from header_parties import *
from ID_troops import *
from ID_factions import *
from ID_map_icons import *

pmf_is_prisoner = 0x0001

####################################################################################################################
#  Each party template record contains the following fields:
#  1) Party-template id: used for referencing party-templates in other files.
#     The prefix pt_ is automatically added before each party-template id.
#  2) Party-template name.
#  3) Party flags. See header_parties.py for a list of available flags
#  4) Menu. ID of the menu to use when this party is met. The value 0 uses the default party encounter system.
#  5) Faction
#  6) Personality. See header_parties.py for an explanation of personality flags.
#  7) List of stacks. Each stack record is a tuple that contains the following fields:
#    7.1) Troop-id. 
#    7.2) Minimum number of troops in the stack. 
#    7.3) Maximum number of troops in the stack. 
#    7.4) Member flags(optional). Use pmf_is_prisoner to note that this member is a prisoner.
#     Note: There can be at most 6 stacks.
####################################################################################################################


party_templates = [
  ("none","none",icon_gray_knight,0,fac_commoners,merchant_personality,[]),
  ("rescued_prisoners","Rescued Prisoners",icon_gray_knight,0,fac_commoners,merchant_personality,[]),
  ("enemy","Enemy",icon_gray_knight,0,fac_outlaws,merchant_personality,[]),
  ("hero_party","Hero Party",icon_gray_knight,0,fac_commoners,merchant_personality,[]),
####################################################################################################################
# Party templates before this point are hard-wired into the game and should not be changed. 
####################################################################################################################
 ("river_pirates","River pirates",icon_axeman|carries_goods(1),0,
   fac_outlaws,bandit_personality,[(trp_ruffian,5,80),(trp_thug,3,40)]),
  ("bandits","Bandits",icon_axeman|carries_goods(1),0,
   fac_outlaws,bandit_personality,[(trp_ruffian,5,50),(trp_thug,5,50),(trp_bandit,3,35),(trp_mounted_bandit,1,25)]),
  ("mountain_bandits","Mountain bandits",icon_khergit|carries_goods(2),0,fac_outlaws,
   bandit_personality,[(trp_bandit,6,70),(trp_mounted_bandit,8,60),(trp_mounted_brigand,5,40)]),
  ("forest_bandits","Forest bandits",icon_axeman|carries_goods(2),0,fac_outlaws,
   bandit_personality,[(trp_bandit,10,60),(trp_mounted_bandit,3,40),(trp_mounted_brigand,5,30)]),
  ("sea_raiders","Wako pirates",icon_axeman|carries_goods(2),0,fac_outlaws,bandit_personality,
   [(trp_bandit,6,75),(trp_mounted_brigand,4,50)]),
  ("bandit_raiders_a","Bandit raiders",icon_khergit|carries_goods(2)|pf_quest_party,0,fac_quest_bandits,
   bandit_personality,[(trp_ruffian,3,20),(trp_bandit,1,15),(trp_mounted_bandit,1,8)]),
  ("bandit_raiders_b","Bandit raiders",icon_khergit|carries_goods(2)|pf_quest_party,0,fac_quest_bandits,
   bandit_personality,[(trp_mounted_bandit,3,46),(trp_mounted_brigand,1,36)]),
  ("bandit_raiders_c","Bandit raiders",icon_khergit|carries_goods(2),0,fac_quest_bandits,
   bandit_personality,[(trp_ruffian,3,20),(trp_bandit,1,15),(trp_mounted_bandit,1,8)]),
  ('spy','Spies',icon_peasant|pf_hide_defenders,0,fac_neutral,
   merchant_personality,[]),
  ("hyogo_police","Hyogo Police",icon_gray_knight,0,fac_samurai,soldier_personality,
   [(trp_t2_spear_samurai_n,1,26),(trp_t2_spear_ashigaru_n,2,13),(trp_t2_bow_ashigaru_n,2,10),(trp_t2_crossbow_ashigaru_n,2,10)]),
  ("police","Police",icon_gray_knight,0,fac_samurai,soldier_personality,
   [(trp_t2_spear_samurai_n,1,26),(trp_t2_spear_ashigaru_n,2,13),(trp_t2_bow_ashigaru_n,2,10),(trp_t2_crossbow_ashigaru_n,2,10)]),
  ("hosokawa_allied_patrol","Hosokawa-allied patrol",icon_gray_knight,0,fac_neutral,soldier_personality,
   [(trp_t3_heavy_cav_h,2,7),(trp_t2_heavy_cav_h,2,7),(trp_t3_light_cav_h,2,17),(trp_t2_spear_samurai_h,3,15),
    (trp_t3_spear_samurai_h,3,15),(trp_t3_bow_ashigaru_h,5,25)]),
  ("yamana_allied_patrol","Yamana-allied patrol",icon_gray_knight,0,fac_neutral,soldier_personality,
   [(trp_t3_heavy_cav_y,2,7),(trp_t2_heavy_cav_y,2,7),(trp_t3_light_cav_y,2,17),(trp_t2_spear_samurai_y,3,15),
    (trp_t3_spear_samurai_y,3,15),(trp_t3_bow_ashigaru_y,5,25)]),
  ("village_patrol","Patrol",0,0,fac_commoners,soldier_personality,
   [(trp_veteran_defender,0,15),(trp_village_defender,4,25),(trp_villager,8,30),(trp_farmer,6,30)]),
  ("town_patrol","Patrol",0,0,fac_commoners,soldier_personality,
   [(trp_t2_light_cav_n,0,25),(trp_t2_spear_samurai_n,3,25),(trp_t3_spear_samurai_n,3,25),(trp_t3_spear_ashigaru_n,2,33),(trp_t2_crossbow_ashigaru_n,2,10)]),
  ("city_patrol","Patrol",0,0,fac_commoners,soldier_personality,
   [(trp_t2_heavy_cav_n,0,35),(trp_t2_light_cav_n,4,35),(trp_t3_spear_samurai_n,4,55),(trp_t3_spear_ashigaru_n,2,43),(trp_t3_crossbow_ashigaru_n,2,20)]),
  ('local_patrol','Patrol',icon_peasant,0,fac_commoners,soldier_personality,[]),

  ("traveling_farmers","Travelling Farmers",icon_mule|carries_goods(1),0,fac_commoners,
   merchant_personality,[(trp_farmer,5,15)]),
  ("traveling_peddler","Traveling Peddler",icon_mule|carries_goods(3),0,fac_merchants,
   merchant_personality,[(trp_merchant,2,5),(trp_farmer,5,10)]),
  ("trade_caravan","Traders",icon_mule,0,fac_merchants,
   merchant_personality,[(trp_merchant,2,5),(trp_farmer,5,10)]),
   ("duelist","Duelist",icon_peasant,0,fac_ronin,merchant_personality,[(trp_duelist,1,1)]),

  ("messenger","Messenger",icon_gray_knight,0,fac_neutral,merchant_personality,
   [(trp_messenger,1,1)]),
  ("ikko_ikki_rabble","Ikko Ikki Rabble",icon_axeman|carries_goods(2)|pf_quest_party,0,fac_ikko_ikki,bandit_personality,
   [(trp_ikko_peasant,8,25),(trp_ikko_rebel,5,15),(trp_souhei_warrior_j,3,10),(trp_souhei_archer_j,3,10)]),
  ("ikko_ikki_rebels","Ikko Ikki Rebels",icon_axeman|carries_goods(3)|pf_quest_party,0,fac_ikko_ikki,bandit_personality,
   [(trp_ikko_peasant,5,15),(trp_ikko_rebel,15,20),(trp_ikko_insurgent,4,15),(trp_souhei_warrior_j,4,15),(trp_souhei_archer_j,4,15)]),
  ("ikko_ikki_insurgents","Ikko Ikki Insurgents",icon_axeman|carries_goods(4)|pf_quest_party,0,fac_ikko_ikki,bandit_personality,
   [(trp_ikko_rebel,20,30),(trp_ikko_insurgent,10,30),(trp_bo_souhei_j,10,20),(trp_naginata_souhei_j,10,20),(trp_yumi_souhei_j,8,15)]),

  ("farmers","Farmers",icon_peasant,0,fac_innocents,merchant_personality,
   [(trp_farmer,11,22),(trp_peasant_woman,16,44)]),
  ("refugees","Refugees",icon_woman,0,fac_innocents,merchant_personality,
   [(trp_refugee,19,48)]),

  ('companions','Companions',icon_gray_knight,0,fac_player_faction,merchant_personality,[]),

  ('fort','Fort',icon_village|pf_show_faction|pf_is_static,0,fac_commoners,0,[]),
  ('fort_patrol','Patrol',icon_gray_knight,0,fac_commoners,soldier_personality,[]),
  ('builder','Builders',icon_peasant,0,fac_neutral,merchant_personality,[(trp_geomancer,1,1)]),
  ('hosokawa_banner','Hosokawa',icon_peasant,0,fac_hosokawa,merchant_personality,[]),
  ('yamana_banner','Yamana',icon_peasant,0,fac_yamana,merchant_personality,[]),
  
  ('empty_template','no name',icon_gray_knight,0,fac_neutral,soldier_personality,[]),
  ('spawn_point','no name',pf_disabled,0,fac_neutral,0,[]),
# reinforcement templates, faction and village/town/city
  ('hosokawa_reinforcements_a','hra',pf_disabled,0,fac_hosokawa,soldier_personality,
	[
		(trp_t5_umanawari_h,2,6),
		(trp_t4_heavy_cav_h,5,15),
		(trp_t4_light_cav_h,10,15),
		(trp_t4_sword_samurai_h,10,20),
		(trp_t4_bow_samurai_h,10,20),
		(trp_t4_spear_samurai_h,12,25),
		]
	),
  ('hosokawa_reinforcements_b','hra',pf_disabled,0,fac_hosokawa,soldier_personality,
	[
		(trp_t3_heavy_cav_h,2,4),
		(trp_t3_light_cav_h,5,10),
		(trp_t2_light_cav_h,5,10),
		(trp_t3_sword_samurai_h,8,15),
		(trp_t3_bow_samurai_h,15,30),
		(trp_t3_spear_samurai_h,15,30),
		]
	),
  ('hosokawa_reinforcements_c','hra',pf_disabled,0,fac_hosokawa,soldier_personality,
	[
		(trp_t2_light_cav_h,5,10),
		(trp_t2_spear_samurai_h,15,30),
		(trp_t3_bow_ashigaru_h,10,30),
		(trp_t3_spear_ashigaru_h,10,30),
		]
	),
  ('hosokawa_reinforcements_d','hra',pf_disabled,0,fac_hosokawa,soldier_personality,
	[
		(trp_t2_spear_samurai_h,10,20),
		(trp_t3_bow_ashigaru_h,10,20),
		(trp_t3_spear_ashigaru_h,10,20),
		(trp_t2_crossbow_ashigaru_h,12,25),
		]
	),
  ('yamana_reinforcements_a','hra',pf_disabled,0,fac_yamana,soldier_personality,
	[
		(trp_t5_umanawari_y,2,6),
		(trp_t4_heavy_cav_y,5,15),
		(trp_t4_light_cav_y,10,15),
		(trp_t4_sword_samurai_y,10,20),
		(trp_t4_bow_samurai_y,10,20),
		(trp_t4_spear_samurai_y,12,25),
		]
	),
  ('yamana_reinforcements_b','hra',pf_disabled,0,fac_yamana,soldier_personality,
	[
		(trp_t3_heavy_cav_y,2,4),
		(trp_t3_light_cav_y,5,10),
		(trp_t2_light_cav_y,5,10),
		(trp_t3_sword_samurai_y,8,15),
		(trp_t3_bow_samurai_y,15,30),
		(trp_t3_spear_samurai_y,15,30),
		]
	),
  ('yamana_reinforcements_c','hra',pf_disabled,0,fac_yamana,soldier_personality,
	[
		(trp_t2_light_cav_y,5,10),
		(trp_t2_spear_samurai_y,15,30),
		(trp_t3_bow_ashigaru_y,10,30),
		(trp_t3_spear_ashigaru_y,10,30),
		]
	),
  ('yamana_reinforcements_d','hra',pf_disabled,0,fac_yamana,soldier_personality,
	[
		(trp_t2_spear_samurai_y,10,20),
		(trp_t3_bow_ashigaru_y,10,20),
		(trp_t3_spear_ashigaru_y,10,20),
		(trp_t2_crossbow_ashigaru_y,12,25),
		]
	),
  ('village_reinforcements_a','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_veteran_defender,2,4),
		(trp_village_defender,5,10),
		(trp_t2_spear_ashigaru_n,5,10),
		(trp_t2_crossbow_ashigaru_n,8,15),
		]
	),
  ('village_reinforcements_b','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_village_defender,5,10),
		(trp_t2_spear_ashigaru_n,5,10),
		(trp_t2_crossbow_ashigaru_n,10,20),
		]
	),
  ('village_reinforcements_c','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_villager,5,10),
		(trp_farmer,8,15),
		]
	),
  ('town_reinforcements_a','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_t3_light_cav_n,5,10),
		(trp_t3_spear_samurai_n,5,10),
		(trp_t3_bow_ashigaru_n,8,15),
		(trp_t3_spear_ashigaru_n,8,15),
		]
	),
  ('town_reinforcements_b','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_t2_spear_samurai_n,5,10),
		(trp_t3_bow_ashigaru_n,8,15),
		(trp_t3_spear_ashigaru_n,8,15),
		]
	),
  ('town_reinforcements_c','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_t3_bow_ashigaru_n,8,15),
		(trp_t4_spear_ashigaru_n,8,15),
		(trp_t3_spear_ashigaru_n,12,20),
		]
	),
  ('city_reinforcements_a','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_t3_heavy_cav_n,5,10),
		(trp_t3_light_cav_n,5,10),
		(trp_t3_spear_samurai_n,10,20),
		(trp_t2_spear_samurai_n,10,20),
		]
	),
  ('city_reinforcements_b','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_t2_light_cav_n,4,8),
		(trp_t2_spear_samurai_n,4,8),
		(trp_t3_bow_ashigaru_n,8,15),
		(trp_t4_spear_ashigaru_n,8,15),
		]
	),
  ('city_reinforcements_c','hra',pf_disabled,0,fac_commoners,soldier_personality,
	[
		(trp_t3_bow_ashigaru_n,10,20),
		(trp_t3_spear_ashigaru_n,10,20),
		(trp_t2_spear_ashigaru_n,12,25),
		]),
  
# Caravans
  ("hosokawa_supply_train","hosokawa_supply_train",icon_gray_knight|carries_goods(5),0,fac_hosokawa,
   merchant_personality,[(trp_t2_light_cav_h,3,10),(trp_t2_spear_ashigaru_h,10,30),(trp_merchant,1,3)]),
  ("yamana_supply_train","yamana_supply_train",icon_gray_knight|carries_goods(5),0,fac_yamana,
   merchant_personality,[(trp_t2_light_cav_y,3,10),(trp_t2_spear_ashigaru_y,10,30),(trp_merchant,1,3)]),

# Prisoner trains
  ("hosokawa_prisoner_train","hosokawa_prisoner_train",icon_gray_knight|carries_goods(5),0,
   fac_hosokawa,merchant_personality,[]),
  ("yamana_prisoner_train","yamana_prisoner_train",icon_gray_knight|carries_goods(5),0,
   fac_yamana,merchant_personality,[]),
  
# Foragers
  ("hosokawa_foragers","hosokawa_foragers",icon_gray_knight|carries_goods(5),0,fac_hosokawa,
   merchant_personality,[(trp_t2_bow_ashigaru_h,6,10),(trp_farmer,6,15)]),
  ("yamana_foragers","yamana_foragers",icon_gray_knight|carries_goods(5),0,fac_yamana,
   merchant_personality,[(trp_t2_bow_ashigaru_y,6,10),(trp_farmer,6,15)]),
  
# Scouts
  ("hosokawa_scouts","Hosokawa Scouts",icon_gray_knight|carries_goods(1),0,fac_hosokawa,
   soldier_personality,[(trp_scout,2,4)]),
  ("yamana_scouts","Yamana Scouts",icon_gray_knight|carries_goods(1),0,fac_yamana,
   soldier_personality,[(trp_scout,2,4)]),

# Patrols
  ("hosokawa_patrol","Hosokawa Patrol",icon_gray_knight|carries_goods(3),0,fac_hosokawa,soldier_personality,[(trp_t5_umanawari_h,1,1)]),
  ("yamana_patrol","Yamana Patrol",icon_gray_knight|carries_goods(3),0,fac_yamana,soldier_personality,[(trp_t5_umanawari_y,1,1)]),

# War Parties
  ("hosokawa_war_party","hosokawa_war_party",icon_gray_knight|carries_goods(5),0,fac_hosokawa,
   soldier_personality,[(trp_taisho,1,1),(trp_t4_heavy_cav_h,0,3),(trp_t3_light_cav_h,6,12),(trp_t3_heavy_cav_h,6,12),
                        (trp_t3_spear_samurai_h,10,20),(trp_t2_bow_ashigaru_h,15,30)]),
  ("yamana_war_party","yamana_war_party",icon_gray_knight|carries_goods(5),0,fac_yamana,
   soldier_personality,[(trp_taisho,1,1),(trp_t4_heavy_cav_y,0,3),(trp_t3_light_cav_y,6,12),(trp_t3_heavy_cav_y,6,12),
                        (trp_t3_spear_samurai_h,10,20),(trp_t2_bow_ashigaru_y,15,30)]),

# Armies
  ('army','Army',icon_gray_knight|carries_goods(7)|carries_gold(3),0,fac_neutral,soldier_personality,[]),
  
# Raiders
  ("hosokawa_raiders","hosokawa_raiders",icon_gray_knight|carries_goods(16)|pf_quest_party,0,
   fac_hosokawa,soldier_personality,[]),
  ("yamana_raiders","yamana_raiders",icon_gray_knight|carries_goods(16)|pf_quest_party,0,
   fac_yamana,soldier_personality,[]),

# Kuge parties
  ("hosokawa_kuge","hosokawa_kuge",icon_gray_knight|carries_goods(5),0,
   fac_hosokawa,merchant_personality,[(trp_kuge,1,2)]),
  ("yamana_kuge","yamana_kuge",icon_gray_knight|carries_goods(5),0,
   fac_yamana,merchant_personality,[(trp_kuge,1,2)]),

# Messenger parties
  ("hosokawa_messenger","Hosokawa messenger",icon_gray_knight,0,
   fac_hosokawa,merchant_personality,[(trp_messenger,1,3)]),
  ("yamana_messenger","Yamana messenger",icon_gray_knight,0,
   fac_yamana,merchant_personality,[(trp_messenger,1,3)]),

# Retinues
  ("hosokawa_retinue","Hosokawa retinue",icon_gray_knight|carries_goods(5),0,
   fac_hosokawa,merchant_personality,[(trp_taisho,1,1),(trp_kuge,0,1),(trp_t4_heavy_cav_h,2,4),(trp_t4_light_cav_h,2,4)]),
  ("yamana_retinue","Yamana retinue",icon_gray_knight|carries_goods(5),0,
   fac_yamana,merchant_personality,[(trp_taisho,1,1),(trp_kuge,0,1),(trp_t4_heavy_cav_y,2,4),(trp_t4_light_cav_y,2,4)]),
##################
#
# NEW STUFF
#
##################
  ("wealthy_traveller","Wealthy Traveller",icon_gray_knight|carries_gold(3600),0,
   fac_neutral,merchant_personality,[(trp_wealthy_samurai,1,1),(trp_yojimbo,1,4)]),
  ("samurai_retinue","Samurai Retinue",icon_gray_knight|carries_gold(1200),0,
   fac_neutral,merchant_personality,[(trp_wealthy_samurai,1,1),(trp_t2_spear_samurai_n,4,12)]),
  ("wanderer","Wanderer",icon_peasant,0,
   fac_neutral,merchant_personality,[(trp_ronin,1,1)]),
  ("travellers","Travellers",icon_peasant,0,
   fac_neutral,merchant_personality,[(trp_villager,1,6)]),
  ("pilgrims","Pilgrims",icon_peasant,0,
   fac_neutral,merchant_personality,[(trp_farmer,1,3),(trp_villager,1,3)]),
  ("monk_pilgrim","Monk Pilgrim",icon_peasant,0,
   fac_neutral,merchant_personality,[(trp_monk_t,1,1)]),
  ("yamabushi","Yamabushi",icon_peasant,0,
   fac_neutral,merchant_personality,[(trp_yamabushi,1,1)]),
  ('array','Array',pf_disabled,0,fac_neutral,0,[]),
  ('shoen','Shoen',pf_disabled,0,fac_neutral,0,[]),
  ('trading_post','tp',pf_disabled,0,fac_neutral,0,[]),
  ('td','td',pf_disabled,0,fac_neutral,0,[]),
  ('facility','facility',pf_disabled,0,fac_neutral,0,[]),
  ('end_objects','eo',pf_disabled,0,fac_neutral,0,[]),
]
